$(function(){
    // loadFoot(0);
    share();
    //TODO:获取信息，主要是邀请码
    $.ajax({
        url:host+'/CMSAPI/GetChannel?openid='+openid+'&cid='+cid,
        success:function(data){
            if(data.state){
                var Number=data.data.Number;
                $('.code-value').html('邀请码：'+Number)
            }
        }
    })
    var index=0;
    var size=10;
    var message=0;
    // var fid=ddid||did;//第一次进来时间初始化的第一列表id  first id
    $('section').dropload({
        scrollArea:window,
        distance:50,
        domUp:{
            domClass : 'dropload-up',
            domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
            domUpdate : '<div class="dropload-update">↑释放更新</div>',
            domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
        },
        domDown:{
            domClass : 'dropload-down',
            domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
            domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData : '<div class="dropload-noData"></div>'
        },
        loadDownFn:function(me){
            index++;
            message++;
            $.ajax({
                url:host+'/CMSAPI/GetChannelList?openid='+openid+'&cid='+cid+'&index='+index+'&size='+size,
                type:'GET',
                dataType:'JSON',
                success:function(data){
                    if(data.state){
                        var msgNum =Math.ceil(data.data.count/size);
                        if (message <=msgNum){
                            var html3='';
                            var list3=data.data.OrderList;
                            $.each(list3,function(i,obj){
                                console.log(obj)
                                var RealName=obj.RealName||'';
                                var partnerOpenid=obj.openid;
                                // var imgUrl=obj.images.length>=1?obj.images[0].URL:'';
                                var NickName=obj.NickName||'';
                                var addr=obj.addr||'0';
                                var Company=obj.Company||'';
                                html3+='<li data-openid="'+partnerOpenid+'">'
                                html3+='    <div class="name">'+RealName+'</div>'
                                html3+='    <div class="phone">'+NickName+'</div>'
                                html3+='    <div class="addr">'+Company+'</div>'
                                html3+='    <i class="fa fa-chevron-right" aria-hidden="true"></i>'
                                html3+='</li>'
                            });
                            $('.tableMain').append(html3);
                        }else {
                            me.lock();
                            me.noData();
                        }
                    }else {
                        alert('网络繁忙，请稍后重试！')
                    }
                    me.resetload();
                }
            })
        }
        // loadUpFn:function(me){
        //     location.reload();
        //     me.resetload();
        // }
    });
    $('.tableMain').on('click','li',function(){
        var partnerOpenid=$(this).attr('data-openid');
        if (partnerOpenid) {
            window.location.href='partnerDetail.html?partnerOpenid='+partnerOpenid;
        } else {
            $.Dialog({
                content: '该合伙人尚未登录，请联系登录！'
            })
        }

    })
    $.ajax({
        url:host+'/mtmlapi/GetChannelQrCode?openid='+openid+'&uid=admins',
        success:function(data){
            if(data.state){
                $('.qr-code-box').html('<img src="'+ data.data.QrCode +'" />')
            }
        }
    })
    $('.qr-code').click(function () {
        $('.box-container').addClass('box-container-active')
        $('.modal').show().unbind('click').click(function () {
            $(this).hide()
            $('.box-container-active').removeClass('box-container-active')
        })
    })
})
